<?php
//开启会话
session_start();
$adminName = trim($_POST['adminName']);
?>
<?php
include_once 'connect.php';
$sql = "select * from text where adminName = '".$_SESSION['loginadmin']." ' ";
$result = mysqli_query($connect,$sql);
if (mysqli_num_rows($result)){
    $text = mysqli_fetch_array($result);
}else{
    header("Location:login.php");
    die("参数错误");
}
//查询数据
//留言
$nub = "select count(id) as shu from leaving";
$res = mysqli_query($connect,$nub);
$leav = mysqli_fetch_array($res);
$shu = $leav['shu'];
//点点滴滴
$dian = "select count(id) as dian from article";
$resdian = mysqli_query($connect,$dian);
$didi = mysqli_fetch_array($resdian);
$diannub = $didi['dian'];
//恋爱清单
$list = "select count(id) as list from lovelist";
$reslsit = mysqli_query($connect,$list);
$listlove = mysqli_fetch_array($reslsit);
$listnub = $listlove['list'];

$liuyan = "select * from leaving order by id desc limit 0,6";
$resliuyan = mysqli_query($connect,$liuyan);

?>
<?php
include_once 'Nav.php';
?>

<div class="row">

    <div class="col-md-6 col-xl-4">
        <div class="card">
            <div class="card-body">
                <div class="row align-items-center">
                    <div class="col-6">
                        <h5 class="text-muted font-weight-normal mt-0 text-truncate" title="Campaign Sent">留言数量</h5>
                        <h3 class="my-2 py-1"><?php echo $shu ?><i>条</i></h3>
                        <p class="mb-0 text-muted">
                            <span class="text-success mr-2"><i class="mdi mdi-arrow-up-bold"></i> 3.27%</span>
                        </p>
                    </div>
                    <div class="col-6">
                        <div class="text-right">
                            <div id="campaign-sent-chart"></div>
                        </div>
                    </div>
                </div> <!-- end row-->
            </div> <!-- end card-body -->
        </div> <!-- end card -->
    </div> <!-- end col -->

    <div class="col-md-6 col-xl-4">
        <div class="card">
            <div class="card-body">
                <div class="row align-items-center">
                    <div class="col-6">
                        <h5 class="text-muted font-weight-normal mt-0 text-truncate" title="New Leads">点点滴滴</h5>
                        <h3 class="my-2 py-1"><?php echo $diannub ?><i>条</i></h3>
                        <p class="mb-0 text-muted">
                            <span class="text-danger mr-2"><i class="mdi mdi-arrow-down-bold"></i> 5.38%</span>
                        </p>
                    </div>
                    <div class="col-6">
                        <div class="text-right">
                            <div id="new-leads-chart"></div>
                        </div>
                    </div>
                </div> <!-- end row-->
            </div> <!-- end card-body -->
        </div> <!-- end card -->
    </div> <!-- end col -->

    <div class="col-md-6 col-xl-4">
        <div class="card">
            <div class="card-body">
                <div class="row align-items-center">
                    <div class="col-6">
                        <h5 class="text-muted font-weight-normal mt-0 text-truncate" title="Deals">恋爱清单</h5>
                        <h3 class="my-2 py-1"><?php echo $listnub ?><i>条</i></h3>
                        <p class="mb-0 text-muted">
                            <span class="text-success mr-2"><i class="mdi mdi-arrow-up-bold"></i> 4.87%</span>
                        </p>
                    </div>
                    <div class="col-6">
                        <div class="text-right">
                            <div id="deals-chart"></div>
                        </div>
                    </div>
                </div> <!-- end row-->
            </div> <!-- end card-body -->
        </div> <!-- end card -->
    </div> <!-- end col -->

</div>
<!-- end row -->
<div class="row">
    <div class="col-12">
        <div class="card">
            <div class="card-body">
                <div class="row mb-2">
                    <div class="col-lg-4">
                        <div class="text-lg-right">
                            <button type="button" class="btn btn-danger mb-2 mr-2"><i class="mdi mdi-basket mr-1"></i> 最新留言</button>
                        </div>
                    </div><!-- end col-->
                </div>

                <div class="table-responsive">
                    <table class="table table-centered mb-0">
                        <thead class="thead-light">
                        <tr>
                            <th style="width: 20px;">
                                <div class="custom-control custom-checkbox">
                                    <input type="checkbox" class="custom-control-input" id="customCheck1">
                                    <label class="custom-control-label" for="customCheck1">&nbsp;</label>
                                </div>
                            </th>
                            <th>评论内容</th>
                            <th>Date</th>
                            <th>Name</th>
                            <th>QQ</th>
                            <th>IP</th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php
                        while ($info = mysqli_fetch_array($resliuyan)) {
                        ?>
                        <tr>
                            <td>
                                <div class="custom-control custom-checkbox">
                                    <input type="checkbox" class="custom-control-input" id="customCheck2">
                                    <label class="custom-control-label" for="customCheck2">&nbsp;</label>
                                </div>
                            </td>
                            <td><?php echo $info['text']?></td>
                            <td>
                                <small class="text-muted"><?php echo $info['time']?></small>
                            </td>
                            <td>
                                <h5><span class="badge badge-success-lighten"><i class="mdi mdi-account-circle mr-1 rihjt-0"></i> <?php echo $info['name']?></span></h5>
                            </td>
                            <td>
                                <?php echo $info['QQ']?>
                            </td>
                            <td>
                                <h5><span class="badge badge-danger-lighten"><?php if ($info['ip']) { ?> <?php echo $info['ip']?> <?php }else{?>127.0.0.1<?php } ?></span></h5>
                            </td>
                        </tr>
                         <?php
                        }
                        ?>

                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>

<?php
include_once 'Footer.php';
?>

</body>
</html>